import java.util.Scanner;

public class Solution {
    public void merge(int[] nums1, int m, int[] nums2, int n){
        int p1 = m-1;
        int p2 = n-1;
        int p = m+n-1;
        while(p1 >= 0 && p2 >= 0){
            if(nums1[p1] > nums2[p2]){
                nums1[p] = nums1[p1];
                p1--;
            }else{
                nums1[p] = nums2[p2];
                p2--;
            }
            p--;
        }
        while(p2 >= 0){
            nums1[p] = nums2[p2];
            p2--;
            p--;
        }
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()){
            int len1 = in.nextInt();
            int len2 = in.nextInt();
            int[] arr1 = new int[len1 + len2];
            int[] arr2 = new int[len2];
            for (int i = 0; i < arr1.length; i++) {
                arr1[i] = in.nextInt();
            }
            for (int i = 0; i < arr2.length; i++) {
                arr2[i] = in.nextInt();
            }
            Solution solution = new Solution();
            solution.merge(arr1,len1,arr2,len2);
            for (int i = 0; i < arr1.length; i++) {
                System.out.print(arr1[i]+" ");
            }
        }
    }
}
